<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lxId">
              <j-dict-select-tag type="list" v-model="model.lxId" dictCode="sb_lx,lx,id" placeholder="请选择类型" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="运营商" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ssyysId">
              <a-input v-model="model.ssyysId" placeholder="请输入运营商"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="mc">
              <a-input v-model="model.mc" placeholder="请输入名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="所属服务" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ssfwId">
              <j-dict-select-tag type="list" v-model="model.ssfwId" dictCode="sb_ssfw,fwms,id" placeholder="请选择所属服务" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dz">
              <a-input v-model="model.dz" placeholder="请输入地址"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="省份" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sheng">
              <a-input v-model="model.sheng" placeholder="请输入省份"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="地市" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shi">
              <a-input v-model="model.shi" placeholder="请输入地市"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="区县" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qu">
              <a-input v-model="model.qu" placeholder="请输入区县"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="省代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shengcode">
              <a-input v-model="model.shengcode" placeholder="请输入省代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="市代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shicode">
              <a-input v-model="model.shicode" placeholder="请输入市代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="区县代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qucode">
              <a-input v-model="model.qucode" placeholder="请输入区县代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="容量/KW" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="rongliang">
              <a-input v-model="model.rongliang" placeholder="请输入容量/KW"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="投运日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yyrq">
              <j-date placeholder="请选择投运日期" v-model="model.yyrq"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="国家代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="gjcode">
              <a-input v-model="model.gjcode" placeholder="请输入国家代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="站点电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zddh">
              <a-input v-model="model.zddh" placeholder="请输入站点电话"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="服务电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fwdh">
              <a-input v-model="model.fwdh" placeholder="请输入服务电话"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="站点类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zdlxId">
              <j-dict-select-tag type="list" v-model="model.zdlxId" dictCode="sb_zdlx,lxms,id" placeholder="请选择站点类型" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="站点状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zdztId">
              <j-dict-select-tag type="list" v-model="model.zdztId" dictCode="sb_zdzt,ztms,id" placeholder="请选择站点状态" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="车位数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cwsl">
              <a-input v-model="model.cwsl" placeholder="请输入车位数量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="站点导引" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zddy">
              <a-input v-model="model.zddy" placeholder="请输入站点导引"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="建设场所" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jscsId">
              <j-dict-select-tag type="list" v-model="model.jscsId" dictCode="sb_jscs,csms,id" placeholder="请选择建设场所" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="适配车型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="spcx">
              <a-input v-model="model.spcx" placeholder="请输入适配车型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="车位楼层及数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cwlcjsl">
              <a-input v-model="model.cwlcjsl" placeholder="请输入车位楼层及数量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="营业时间描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yysjms">
              <a-input v-model="model.yysjms" placeholder="请输入营业时间描述"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="充电费描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cdfms">
              <a-input v-model="model.cdfms" placeholder="请输入充电费描述"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="服务费描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fwfms">
              <a-input v-model="model.fwfms" placeholder="请输入服务费描述"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否免费停车" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ismftc">
              <j-dict-select-tag type="list" v-model="model.ismftc" dictCode="sb_sfxz,sfms,id" placeholder="请选择是否免费停车" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="停车费描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tcfms">
              <a-input v-model="model.tcfms" placeholder="请输入停车费描述"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="支付方式描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zffsms">
              <a-input v-model="model.zffsms" placeholder="请输入支付方式描述"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="电站识别码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dzsbm">
              <a-input v-model="model.dzsbm" placeholder="请输入电站识别码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="预约状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yyztId">
              <j-dict-select-tag type="list" v-model="model.yyztId" dictCode="sb_yyzt,ztms,id" placeholder="请选择预约状态" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否全天开放" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isqtkf">
              <j-dict-select-tag type="list" v-model="model.isqtkf" dictCode="sb_sfxz,sfms,id" placeholder="请选择是否全天开放" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="运营商ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yysid">
              <a-input v-model="model.yysid" placeholder="请输入运营商ID"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="设备所属放ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sbssfid">
              <a-input v-model="model.sbssfid" placeholder="请输入设备所属放ID"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="经度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jd">
              <a-input v-model="model.jd" placeholder="请输入经度"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="纬度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wd">
              <a-input v-model="model.wd" placeholder="请输入纬度"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="备注信息" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bzms">
              <a-input v-model="model.bzms" placeholder="请输入备注信息"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'SbCdzForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/sbcdz/sbCdz/add",
          edit: "/sbcdz/sbCdz/edit",
          queryById: "/sbcdz/sbCdz/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>